<?xml version="1.0" encoding="UTF-8"?>
<!--=======================================================================
	Copyright:	umlungu consulting (pty) ltd
	Author:		Alan Benington
	Started:	2008-06-14
	Status:		release	
	Version:	2.0.0
	Build:		20080614
	License:	GNU General Public License
	======================================================================= -->

<!--=======================================================================
	Development Notes:
	==================
	20080614:	Initial release.
	=======================================================================	-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--=============
	Base template
	============= -->

	<xsl:template match="grpform">
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="@name">
					<xsl:value-of select="@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>nm_form</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div id="rprt-grp">
			<form method="post">
				<xsl:call-template name="ReportForm"/>
				<xsl:call-template name="ReportSort"/>
				<div class="rprt-pop">
					<div class="rprt-hd">
						<div class="rprt-hd-cnt">
							<div class="rprt-logo">
								<img src="images/ver5/nm_logo_tnsp.gif" alt="Nashua Mobile"/>
							</div>
							<xsl:call-template name="ReportTitle"/>
							<xsl:choose>
								<xsl:when test="$device='print' or $device='email'">
									<xsl:call-template name="ReportPrintEmailHeader"/>
								</xsl:when>
								<xsl:when test="$device='pdf' or $device='pdfout'">
								</xsl:when>
								<xsl:otherwise>
									<xsl:call-template name="ReportFaqEmailDown"/>
								</xsl:otherwise>
							</xsl:choose>
						</div>
					</div>
					<xsl:choose>
						<xsl:when test="$device='pdf' or ($device='pdfout' and pdf/@summary='yes')">
							<xsl:if test="@total='yes' or summary">
								<div class="rprt-spt">
									<xsl:call-template name="ReportSummary"/>
								</div>
							</xsl:if>
						</xsl:when>
						<xsl:when test="$device='email' or $device='print'">
							<xsl:if test="@total='yes' or summary">
								<div class="rprt-spt">
									<xsl:call-template name="ReportSummary"/>
								</div>
							</xsl:if>
						</xsl:when>
						<xsl:otherwise>
							<div class="rprt-spt">
								<div class="rprt-shdw">
									<call-template name="nobrspace"/>
								</div>
								<xsl:call-template name="ReportFilters"/>
								<xsl:call-template name="ReportSummary"/>
								<div>
									<xsl:call-template name="ReportTabs"/>
								</div>
							</div>
						</xsl:otherwise>
					</xsl:choose>
					<div class="rprt-out">
						<xsl:choose>
							<xsl:when test="$device='pdf'">
								<div class="rprt-wht" id="Report-About-rgn">
									<xsl:apply-templates select="about"/>
								</div>
								<div class="rprt-wht" id="Report-Graph-rgn">
									<xsl:apply-templates select="chart"/>
								</div>
								<xsl:call-template name="ReportAdd"/>
								<xsl:call-template name="ReportData"/>
								<xsl:call-template name="ReportNav"/>
							</xsl:when>
							<xsl:when test="$device='pdfout'">
								<xsl:if test="pdf/@about='yes'">
									<div class="rprt-wht">
										<xsl:apply-templates select="about"/>
									</div>
								</xsl:if>
								<xsl:if test="pdf/@graph='yes'">
									<div class="rprt-wht">
										<xsl:apply-templates select="chart"/>
									</div>
								</xsl:if>
								<xsl:if test="pdf/@data='yes'">
									<xsl:call-template name="ReportAdd"/>
									<xsl:call-template name="ReportData"/>
									<xsl:call-template name="ReportNav"/>
								</xsl:if>
							</xsl:when>
							<xsl:otherwise>
								<xsl:choose>
									<xsl:when test="filters/filter[@name='LCR_Filter_CD' or @name='MSFilter_CD'][value='about']">
										<div class="rprt-wht">
											<xsl:apply-templates select="about"/>
										</div>
									</xsl:when>
									<xsl:when test="filters/filter[@name='LCR_Filter_CD' or @name='MSFilter_CD'][value='graph']">
										<div class="rprt-wht">
											<xsl:apply-templates select="chart"/>
										</div>
									</xsl:when>
									<xsl:otherwise>
										<xsl:call-template name="ReportAdd"/>
										<xsl:call-template name="ReportData"/>
										<xsl:call-template name="ReportNav"/>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</div>
				</div>
			</form>
		</div>
	</xsl:template>

	<!--=======================
	Match templates section
	======================= -->


	<xsl:template match="section/download">
	</xsl:template>

	<xsl:template match="grpform/title">
		<div class="rprt-cnt-lf">
			<h3>
				<xsl:apply-templates/>
			</h3>
		</div>
	</xsl:template>

	<xsl:template match="grpform/subtitle">
		<div class="rprt-cnt-lf">
			<h4>
				<xsl:apply-templates/>
			</h4>
		</div>
	</xsl:template>

	<xsl:template match="grpform/about">
		<xsl:apply-templates />
	</xsl:template>

	<xsl:template match="grpform/title/crumbs">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="grpform/title/crumbs/crumb">
		<xsl:if test="position()!=1">
			<xsl:text> | </xsl:text>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="grpform/head" mode="columns">
		<colgroup>
			<xsl:apply-templates select="heading[not(@type) 
											or @type='pop' 
											or @type='item-add' 
											or @type='item-enum' 
											or @type='item-date' 
											or @type='item-time' 
											or @type='edit-check' 
											or @type='item-check-multi' 
											or @type='item-edit-multi' 
											or @type='item-del-multi' 
											or @type='item-add-multi'
											or @type='item-radio']" mode="columns"/>
		</colgroup>
		<xsl:if test="heading[@type][@type!='item-add' 
									and @type!='pop' 
									and @type!='item-enum' 
									and @type!='item-date' 
									and @type!='item-time' 
									and @type!='item-check-multi' 
									and @type!='item-edit-multi' 
									and @type!='item-del-multi' 
									and @type!='item-add-multi'
									and @type!='item-radio']">
			<colgroup id="act">
				<xsl:apply-templates select="heading[@type 
														and @type!='pop' 
														and @type!='item-add' 
														and @type!='item-enum' 
														and @type!='item-date' 
														and @type!='item-time' 
														and @type!='item-check-multi' 
														and @type!='item-edit-multi' 
														and @type!='item-del-multi' 
														and @type!='item-add-multi'
														and @type!='item-radio']" mode="columns-action"/>
			</colgroup>
		</xsl:if>
	</xsl:template>

	<xsl:template match="head/heading" mode="columns">
		<xsl:variable name="sort_order">
			<xsl:choose>
				<xsl:when test="ancestor::grpform/@ordercol!=''">
					<xsl:value-of select="ancestor::grpform/@ordercol"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="ancestor::grpform/pages/orderColumn"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<col>
			<xsl:attribute name="name">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<xsl:if test="@width">
				<xsl:attribute name="width">
					<xsl:value-of select="@width"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@sort=$sort_order or @name=$sort_order">
				<xsl:attribute name="class">grp-msg-text</xsl:attribute>
			</xsl:if>
		</col>
	</xsl:template>

	<xsl:template match="head/heading" mode="columns-action">
		<col>
			<xsl:attribute name="name">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<xsl:if test="@width">
				<xsl:attribute name="width">
					<xsl:value-of select="@width"/>
				</xsl:attribute>
			</xsl:if>
		</col>
	</xsl:template>

	<xsl:template match="grpform/head">
		<tr>
			<xsl:apply-templates select="heading[not(@type) 
										or @type='item-add'
										or @type='pop'
										or @type='item-enum' 
										or @type='item-date' 
										or @type='item-time' 
										or @type='edit-check' 
										or @type='item-edit-multi' 
										or @type='item-del-multi' 
										or @type='item-add-multi'
										or @type='item-radio']"/>
			<xsl:if test="heading[@type][@type!='item-add' 
										and @type!='pop'
										and @type!='item-enum'
										and @type!='item-check-multi' 
										and @type!='item-edit-multi' 
										and @type!='item-del-multi' 
										and @type!='item-add-multi']">
				<!-- apply same class as data (see template name="ItemType) 
					<xsl:if test="">-->
				<th>
					<xsl:choose>
						<xsl:when test="$device='print' or $device='email'">
							<xsl:attribute name="colspan">0</xsl:attribute>
							<xsl:attribute name="style">width:0px;border:none;</xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute name="class">td-aed</xsl:attribute>
							<xsl:if test="@type!='item-check-multi'">
								<xsl:attribute name="class">td-chk</xsl:attribute>
							</xsl:if>
							<xsl:attribute name="colspan">
								<xsl:value-of select="count(heading[@type][@type!='item-add' 
																		and @type!='pop' 
																		and @type!='item-enum' 
																		and @type!='item-check-multi' 
																		and @type!='item-edit-multi' 
																		and @type!='item-del-multi'
																		and @type!='item-add-multi'])"/>
							</xsl:attribute>
							<xsl:apply-templates select="heading[@type='item-add' 
														or @type='item-add-multi'
														or @type='menubutton' 
														or @type='item-query'
														or @type='item-del'
														or @type='item-edit'
														or @type='item-go'
														or @type='item-btn'
														or @type='item-drop'
														or @type='item-drop-values'
														or @type='item-check']" mode="action"/>
						</xsl:otherwise>
					</xsl:choose>
				</th>
			</xsl:if>
			<xsl:apply-templates select="heading[@type='item-check-multi']"/>
		</tr>
	</xsl:template>

	<xsl:template match="head/heading">
		<xsl:variable name="sort_order">
			<xsl:choose>
				<xsl:when test="ancestor::grpform/@ordercol!=''">
					<xsl:value-of select="ancestor::grpform/@ordercol"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="ancestor::grpform/pages/orderColumn"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thisval">
			<xsl:choose>
				<xsl:when test="@type='item-edit-multi'">Edit</xsl:when>
				<xsl:when test="@type='item-del-multi'">Delete</xsl:when>
				<xsl:when test="contains(text(), '&#xA;')">
					<xsl:value-of select="substring-before(text(), '&#xA;')"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="text()"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<th>
			<xsl:if test="@format='rand' or @format='percent' or @format='number'">
				<xsl:attribute name="class">
					<xsl:text>rht</xsl:text>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@wrapping='no'">
				<xsl:attribute name="nowrap">nowrap</xsl:attribute>
			</xsl:if>
			<xsl:choose>
				<xsl:when test="@type='item-check-multi'">
					<xsl:attribute name="class">td-chk</xsl:attribute>
					<xsl:call-template name="HeadButton">
						<xsl:with-param name="label">
							<xsl:value-of select="text()"/>
						</xsl:with-param>
					</xsl:call-template>
				</xsl:when>
				<xsl:when test="@type='item-edit-multi'">
					<xsl:attribute name="class">td-aed</xsl:attribute>
					<xsl:call-template name="HeadButton">
						<xsl:with-param name="label">Edit</xsl:with-param>
					</xsl:call-template>
				</xsl:when>
				<xsl:when test="@type='item-del-multi'">
					<xsl:attribute name="class">td-aed</xsl:attribute>
					<xsl:call-template name="HeadButton">
						<xsl:with-param name="label">Delete</xsl:with-param>
					</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
					<input type="Button">
						<xsl:attribute name="class">
							<xsl:choose>
								<xsl:when test="@sort=$sort_order or @name=$sort_order">rprt-srt-btn-ac</xsl:when>
								<xsl:otherwise>rprt-srt-btn</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
						<xsl:if test="@sort">
							<xsl:attribute name="title">
								<xsl:choose>
									<xsl:when test="prompt or hint">
										<xsl:value-of select="prompt"/>&#160;<xsl:value-of select="hint"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>Click to sort by column</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:attribute>
							<xsl:attribute name="onclick">
								<xsl:choose>
									<xsl:when test="ancestor::grpform/@xslsort='yes'">
										<xsl:text>javascript:nm_grp.SortOrder('</xsl:text>
									</xsl:when>
									<xsl:otherwise>
										<xsl:text>javascript:nm_grp.Sort('</xsl:text>
									</xsl:otherwise>
								</xsl:choose>
								<xsl:value-of select="@sort"/>
								<xsl:text>', </xsl:text>
								<xsl:choose>
									<xsl:when test="ancestor::grpform/@name">
										<xsl:value-of select="ancestor::grpform/@name"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="$name_grp"/>
									</xsl:otherwise>
								</xsl:choose>
								<xsl:text>, '</xsl:text>
								<xsl:apply-templates select="ancestor::grpform/action"/>
								<xsl:text>');</xsl:text>
							</xsl:attribute>
						</xsl:if>
						<xsl:attribute name="value">
							<xsl:value-of select="$thisval"/>
						</xsl:attribute>
					</input>
				</xsl:otherwise>
			</xsl:choose>
		</th>
	</xsl:template>

	<xsl:template match="head/heading" mode="action">
		<xsl:attribute name="class">td-aed</xsl:attribute>
		<xsl:choose>
			<xsl:when test="@type='item-add'">
				<xsl:variable name="label">
					<xsl:choose>
						<xsl:when test="button">
							<xsl:value-of select="button"/>
						</xsl:when>
						<xsl:otherwise>Add</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:call-template name="HeadButton">
					<xsl:with-param name="label">
						<xsl:value-of select="$label"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="@type='item-drop-values'">
				<xsl:call-template name="HeadButton">
					<xsl:with-param name="label">Submit</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="@type='item-add-multi'">
				<xsl:call-template name="HeadButton">
					<xsl:with-param name="label">Add</xsl:with-param>
					<xsl:with-param name="multi">yes</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="head/heading" mode="add-multi">
		<div class="add-multi">
			<xsl:if test="prompt!=''">
				<h4>
					<xsl:value-of select="prompt"/>
				</h4>
			</xsl:if>
			<xsl:call-template name="HeadButton">
				<xsl:with-param name="label">Add</xsl:with-param>
				<xsl:with-param name="multi">yes</xsl:with-param>
			</xsl:call-template>
		</div>
	</xsl:template>

	<xsl:template match="grpform/items">
		<xsl:call-template name="ReportItems"/>
	</xsl:template>

	<xsl:template match="item">
		<xsl:variable name="thisitem" select="."/>
		<xsl:variable name="thispos" select="position()"/>
		<tr>
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="position() mod 2 = 1">
						<xsl:text>odd</xsl:text>
					</xsl:when>
					<xsl:when test="position() mod 2 = 0">
						<xsl:text>evn</xsl:text>
					</xsl:when>
				</xsl:choose>
			</xsl:attribute>
			<xsl:for-each select="ancestor::grpform/head/heading">
				<xsl:variable name="thisname" select="@name"/>
				<xsl:variable name="thisitem_id" select="@id"/>
				<xsl:variable name="thisid">
					<xsl:choose>
						<xsl:when test="@id">
							<xsl:value-of select="$thisitem/attribute::*[name()=$thisitem_id]"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select='$thisitem/@id'/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:variable>
				<xsl:choose>
					<xsl:when test="@type='pop'">
						<xsl:call-template name="ItemPop">
							<xsl:with-param name="item" select="$thisitem"/>
							<xsl:with-param name="value" select="$thisitem/@*[name()=$thisname]"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type 
							and @type!='item-add' 
							and @type!='pop' 
							and @type!='edit-check' 
							and @type!='item-add-multi'">
						<xsl:call-template name="ItemType">
							<xsl:with-param name="item" select="$thisitem"/>
							<xsl:with-param name="value" select="$thisitem/@*[name()=$thisname]"/>
							<xsl:with-param name="id" select="$thisid"/>
							<xsl:with-param name="position" select="$thispos"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="Item">
							<xsl:with-param name="value" select="$thisitem/@*[name()=$thisname]"/>
							<xsl:with-param name="id" select="$thisid"/>
							<xsl:with-param name="position" select="$thispos"/>
							<xsl:with-param name="ptr" select="$thisitem/attribute::*[name()=$thisitem_id]"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:for-each>
		</tr>
	</xsl:template>

	<xsl:template match="grpform/filters">
		<xsl:apply-templates select="filter"/>
	</xsl:template>

	<xsl:template match="filter">
		<div class="rprt-pop-cnt">
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="position() mod 2 = 1">
						<xsl:text>rprt-pop-cnt-odd</xsl:text>
					</xsl:when>
					<xsl:when test="position() mod 2 = 0">
						<xsl:text>rprt-pop-cnt-evn</xsl:text>
					</xsl:when>
				</xsl:choose>
			</xsl:attribute>
			<div>
				<xsl:apply-templates select="prompt"/>
				<xsl:choose>
					<xsl:when test="@type='search'">
						<xsl:call-template name="InputText"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="SelectDrop">
							<xsl:with-param name="noclass">no</xsl:with-param>
							<xsl:with-param name="mandatory">N</xsl:with-param>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
				<input class="rprt-btn aed" type="Button" value="Go">
					<xsl:attribute name="onclick">
						<xsl:choose>
							<xsl:when test="action">
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="checks">yes</xsl:with-param>
									<xsl:with-param name="secure">yes</xsl:with-param>
									<xsl:with-param name="form">
										<xsl:choose>
											<xsl:when test="ancestor::grpform/@name">
												<xsl:value-of select="ancestor::grpform/@name"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="$name_grp"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:with-param>
									<xsl:with-param name="type">
										<xsl:value-of select="action/@type"/>
									</xsl:with-param>
									<xsl:with-param name="link">
										<xsl:choose>
											<xsl:when test="action/@link">
												<xsl:value-of select="action/@link"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="$link"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:with-param>
									<xsl:with-param name="name">
										<xsl:value-of select="action/@name"/>
									</xsl:with-param>
									<xsl:with-param name="proc">
										<xsl:value-of select="action/@process"/>
									</xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>javascript:</xsl:text>
								<xsl:choose>
									<xsl:when test="ancestor::grpform/@name">
										<xsl:value-of select="ancestor::grpform/@name"/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select="$name_grp"/>
									</xsl:otherwise>
								</xsl:choose>
								<xsl:text>.submit();</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:attribute>
				</input>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="filter/prompt">
		<h4>
			<xsl:apply-templates/>
		</h4>
	</xsl:template>

	<xsl:template match="grpform/filters" mode="tabs">
		<xsl:apply-templates mode="tabs"/>
	</xsl:template>

	<xsl:template match="filter" mode="tabs">
		<input type="Hidden">
			<xsl:attribute name="id">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<xsl:attribute name="name">
				<xsl:value-of select="@name"/>
			</xsl:attribute>
			<xsl:attribute name="value">
				<xsl:value-of select="value"/>
			</xsl:attribute>
		</input>
		<xsl:apply-templates mode="tabs" select="subobjs"/>
	</xsl:template>

	<xsl:template match="subobjs" mode="tabs">
		<ul class="rprt-pop-tabs">
			<xsl:apply-templates mode="tabs"/>
		</ul>
	</xsl:template>

	<xsl:template match="subwf_obj" mode="tabs">
		<xsl:variable name="thisval" select="value"/>
		<li>
			<xsl:choose>
				<xsl:when test="value/lnk">
					<a>
						<xsl:attribute name="href">
							<xsl:call-template name="url">
								<xsl:with-param name="link" select="value/lnk/@name"/>
							</xsl:call-template>
						</xsl:attribute>
						<xsl:apply-templates select="prompt" mode="tabs"/>
					</a>
				</xsl:when>
				<xsl:otherwise>
					<a>
						<xsl:if test="ancestor::*/filter/value=$thisval">
							<xsl:attribute name="class">
								ac<xsl:if test="position()=1">-l</xsl:if>
							</xsl:attribute>
						</xsl:if>
						<xsl:attribute name="href">
							<xsl:text>javascript:nm_grp.Set(</xsl:text>
							<xsl:choose>
								<xsl:when test="ancestor::grpform/@name">
									<xsl:value-of select="ancestor::grpform/@name"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$name_grp"/>
								</xsl:otherwise>
							</xsl:choose>
							<xsl:text>, '</xsl:text>
							<xsl:value-of select="ancestor::filters/filter/@name"/>
							<xsl:text>', '</xsl:text>
							<xsl:value-of select="value"/>
							<xsl:text>')</xsl:text>
						</xsl:attribute>
						<xsl:apply-templates select="prompt" mode="tabs"/>
					</a>
				</xsl:otherwise>
			</xsl:choose>
		</li>
	</xsl:template>

	<xsl:template match="subwf_obj/prompt" mode="tabs">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="subwf_obj/value" mode="tabs">
	</xsl:template>

	<!-- date filter: -->

	<xsl:template match="grpform/filters" mode="date">
		<div class="report-cnt">
			<xsl:apply-templates mode="date"/>
		</div>
	</xsl:template>

	<xsl:template match="filter" mode="date">
		<div class="p-tx">
			<xsl:value-of select="prompt"/>
		</div>
		<xsl:choose>
			<xsl:when test="parent::*/@date='nm_date'">
				<xsl:call-template name="SelectDate">
					<xsl:with-param name="issub">yes</xsl:with-param>
					<xsl:with-param name="thisname" select="@name"/>
					<xsl:with-param name="thisid" select="@name"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="parent::*/@date='nm_date_range'">
				<xsl:call-template name="InputDateRange"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="InputText"/>
			</xsl:otherwise>
			<!-- ie nm_date_text -->
		</xsl:choose>
		<input class="rprt-btn aed" type="Button" value="Go">
			<xsl:attribute name="onclick">
				<xsl:text>javascript:</xsl:text>
				<xsl:choose>
					<xsl:when test="ancestor::grpform/@name">
						<xsl:value-of select="ancestor::grpform/@name"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$name_grp"/>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:text>.submit();</xsl:text>
			</xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template match="grpform/summary">
		<xsl:variable name="totcount">
			<xsl:value-of select="count(./totals)"/>
		</xsl:variable>
		<div class="rprt-summ-bx" id="Report-Summary-rgn">
			<xsl:if test="$totcount &gt; 1">
				<xsl:attribute name="class">rprt-summ-bx-grp</xsl:attribute>
			</xsl:if>
			<table>
				<xsl:apply-templates/>
			</table>
		</div>
	</xsl:template>

	<xsl:template match="grpform/summary/totals">
		<tr>
			<xsl:if test="@empty='yes'">
				<td class="rprt-sum-tx-emp"></td>
			</xsl:if>
			<xsl:apply-templates select="total" mode="label"/>
		</tr>
		<tr>
			<xsl:if test="@labelhor!=''">
				<td class="rprt-sum-tx-hr">
					<xsl:value-of select="@labelhor"/>
				</td>
			</xsl:if>
			<xsl:apply-templates select="total" mode="value"/>
		</tr>
	</xsl:template>

	<xsl:template match="total" mode="label">
		<xsl:if test="not(@selective_disp=.)">
			<xsl:choose>
				<xsl:when test="@label!=''">
					<td class="rprt-sum-tx">
						<xsl:value-of select="@label"/>
					</td>
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

	<xsl:template match="total" mode="value">
		<xsl:if test="not(@selective_disp=.)">
			<td class="rprt-sum-tot-tx">
				<xsl:choose>
					<xsl:when test="../@format='number'">
						<xsl:value-of select="format-number(., '#,##0')"/>
					</xsl:when>
					<xsl:when test="../@format='currency'">
						<xsl:text>R</xsl:text>
						<xsl:value-of select="format-number(., '#,##0.00')"/>
					</xsl:when>
					<xsl:when test="../@format='percentage'">
						<xsl:value-of select="format-number(., '#,##0.00')"/>
						<xsl:text>%</xsl:text>
					</xsl:when>
					<xsl:when test="@format='number'">
						<xsl:value-of select="format-number(., '#,##0')"/>
					</xsl:when>
					<xsl:when test="@format='currency'">
						<xsl:text>R</xsl:text>
						<xsl:value-of select="format-number(., '#,##0.00')"/>
					</xsl:when>
					<xsl:when test="@format='percentage'">
						<xsl:value-of select="format-number(., '#,##0.00')"/>
						<xsl:text>%</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates/>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</xsl:if>
	</xsl:template>

	<xsl:template match="grpform/summary/break">
		<tr>
			<td class="rprt-sum-tx-emp">
				<xsl:attribute name="colspan">
					<xsl:value-of select="@cells"/>
				</xsl:attribute>
				<xsl:call-template name="nobrspace"/>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="grpform/button">
		<input type="Button" class="fm-btn">
			<xsl:if test="@important='yes'">
				<xsl:attribute name="class">fm-btn-im</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="value">
				<xsl:value-of select="@label"/>
			</xsl:attribute>
			<xsl:attribute name="onclick">
				<xsl:call-template name="ButtonAction">
					<xsl:with-param name="checks">yes</xsl:with-param>
					<xsl:with-param name="secure">yes</xsl:with-param>
					<xsl:with-param name="form">
						<xsl:choose>
							<xsl:when test="ancestor::grpform/@name">
								<xsl:value-of select="ancestor::grpform/@name"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$name_grp"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:with-param>
					<xsl:with-param name="type">
						<xsl:value-of select="@type"/>
					</xsl:with-param>
					<xsl:with-param name="link">
						<xsl:value-of select="@link"/>
					</xsl:with-param>
					<xsl:with-param name="name">
						<xsl:value-of select="@name"/>
					</xsl:with-param>
					<xsl:with-param name="proc">
						<xsl:value-of select="@process"/>
					</xsl:with-param>
				</xsl:call-template>
			</xsl:attribute>
		</input>
	</xsl:template>

	<!--=======================
	Named templates section
	======================= -->

	<xsl:template name="ReportFaqEmailDown">
		<div class="rprt-hlp">
			<xsl:if test="parent::*/@faqs!='no' or not(parent::*/@faqs)">
				<a>
					<xsl:attribute name="href">
						<xsl:text>Javascript:nm_pge.PopFaq('</xsl:text>
						<xsl:call-template name="simple-link">
							<xsl:with-param name="link">
								<xsl:text>faq_</xsl:text>
								<xsl:value-of select="$link"/>
							</xsl:with-param>
							<!-- delete?
							<xsl:with-param name="id">
								<xsl:text>ver5_faq</xsl:text>
							</xsl:with-param>
							-->
						</xsl:call-template>
						<!-- delete?
						<xsl:text>&amp;faq_sect=</xsl:text>
						<xsl:value-of select="$this_sect"/>
						<xsl:text>&amp;faq_subs=</xsl:text>
						<xsl:value-of select="$this_sub"/>
						<xsl:text>&amp;faq_proc=</xsl:text>
						<xsl:value-of select="$this_proc"/>
						-->
						<xsl:text>')</xsl:text>
					</xsl:attribute>
					<img src="images/ver5/icons/help.gif" width="22px" height="22px"/>
				</a>
			</xsl:if>
			<xsl:if test="parent::*/@print!='no' or not(parent::*/@print)">
				<div id="rprt-hlp-pr">

					<a>
						<xsl:attribute name="href">
							<xsl:apply-templates select="action"/>
							<xsl:text>&amp;device=print</xsl:text>
						</xsl:attribute>
						<img src="images/ver5/icons/print.gif" title="Print this page"/>
					</a>
				</div>
			</xsl:if>
			<xsl:if test="parent::*/@email!='no' or not(parent::*/@email)">
				<div id="rprt-hlp-em">
					<a>
						<xsl:attribute name="href">
							<xsl:apply-templates select="action"/>
							<xsl:text>&amp;device=email</xsl:text>
						</xsl:attribute>
						<img src="images/ver5/icons/email.gif" title="Email this page"/>
					</a>
				</div>
			</xsl:if>
			<xsl:if test="parent::*/@schedule!='no' or not(parent::*/@schedule)">
				<div id="rprt-hlp-sh">
					<a>
						<xsl:attribute name="href">
							<xsl:apply-templates select="parent::*/schedule/action"/>
						</xsl:attribute>
						<img src="images/ver5/icons/schedule.gif" title="Add this page to my downloads"/>
					</a>
				</div>
			</xsl:if>
			<xsl:if test="parent::*/@download!='no' or not(parent::*/@download)">
				<div id="rprt-hlp-dl">
					<a>
						<xsl:attribute name="href">
							<xsl:apply-templates select="parent::*/download/action"/>
							<xsl:text>&amp;device=csv</xsl:text>
						</xsl:attribute>
						<img src="images/ver5/icons/downloadcsv.gif" title="Download this page"/>
					</a>
				</div>
			</xsl:if>
			<xsl:if test="parent::*/@pdf!='no' or not(parent::*/@pdf)">
				<div id="rprt-hlp-sh">
					<a>
						<xsl:attribute name="href">
							<xsl:text>javascript:nm_pge.GetPDF()</xsl:text>
						</xsl:attribute>
						<img src="images/ver5/icons/downloadpdf.gif" title="Download this page as PDF"/>
					</a>
				</div>
			</xsl:if>
		</div>
	</xsl:template>

	<xsl:template name="Summary">
		<xsl:variable name="totel" select="total"/>
		<xsl:variable name="tots" select="count(./head/heading[@total='yes'])"/>
		<xsl:if test="$tots>0">
			<div class="rprt-shdw">
				<call-template name="nobrspace"/>
			</div>
		</xsl:if>
		<div class="rprt-summ-bx" id="Report-Summary-rgn">
			<table>
				<tr>
					<xsl:for-each select="head/heading[@total='yes']">
						<td class="rprt-sum-tx">
							<xsl:value-of select="text()"/>
						</td>
					</xsl:for-each>
				</tr>
				<tr>
					<xsl:for-each select="head/heading[@total='yes']">
						<xsl:variable name="totattr" select="@name"/>
						<xsl:variable name="totfrmt" select="@format"/>
						<xsl:variable name="totvalu" select="$totel/attribute::*[name()=$totattr]"/>
						<td class="rprt-sum-tot-tx">
							<xsl:choose>
								<xsl:when test="not($totvalu) or $totvalu='' or $totvalu='Null' or $totvalu='NULL'">
									<xsl:text>No data</xsl:text>
								</xsl:when>
								<xsl:when test="$totfrmt='rand'">
									<xsl:text>R&#160;</xsl:text>
									<xsl:value-of select="format-number($totvalu, '###,###.00')"/>
								</xsl:when>
								<xsl:when test="$totfrmt='percent'">
									<xsl:value-of select="format-number($totvalu, '###.0')"/>
									<xsl:text>%</xsl:text>
								</xsl:when>
								<xsl:when test="$totfrmt='integer'">
									<xsl:number value="$totvalu" format="1"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$totvalu"/>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</xsl:for-each>
				</tr>
			</table>
		</div>
	</xsl:template>

	<xsl:template name="ReportItems">
		<xsl:variable name="sort_order">
			<xsl:choose>
				<xsl:when test="ancestor-or-self::*/grpform/@ordercol!=''">
					<xsl:value-of select="ancestor-or-self::*/grpform/@ordercol"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="ancestor-or-self::*/grpform/pages/orderColumn"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$sort_order!=''">
				<xsl:choose>
					<xsl:when test="ancestor-or-self::*/head/heading[@sort=$sort_order]/@number='yes'">
						<xsl:apply-templates select="item">
							<xsl:sort select="attribute::*[position()=number($sort_order)]" data-type="number"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="ancestor-or-self::*/head/heading[@sort=$sort_order]/@descending='yes'">
						<xsl:apply-templates select="item">
							<xsl:sort order="descending" select="attribute::*[position()=number($sort_order)]"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="item">
							<xsl:sort select="attribute::*[position()=number($sort_order)]"/>
						</xsl:apply-templates>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="item"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="ReportForm">
		<xsl:attribute name="action">
			<xsl:apply-templates select="action"/>
		</xsl:attribute>
		<xsl:attribute name="name">
			<xsl:choose>
				<xsl:when test="@name">
					<xsl:value-of select="@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$name_grp"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
		<xsl:if test="@pages='yes'">
			<script language="JavaScript">
				<xsl:text>document.</xsl:text>
				<xsl:choose>
					<xsl:when test="@name">
						<xsl:value-of select="@name"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$name_grp"/>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:text>.onkeypress = nm_pge.KeyPress</xsl:text>
			</script>
		</xsl:if>
	</xsl:template>

	<xsl:template name="ReportSort">
		<input type="Hidden" name="Order_Col" value=""/>
		<input type="Hidden" name="Sort_Col">
			<xsl:attribute name="value">
				<xsl:choose>
					<xsl:when test="@ordercol">
						<xsl:value-of select="@ordercol"/>
					</xsl:when>
					<xsl:when test="pages/orderColumn">
						<xsl:value-of select="pages/orderColumn"/>
					</xsl:when>
					<xsl:otherwise></xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="ReportTitle">
		<xsl:if test="title!=''">
			<div class="rprt-bx">
				<xsl:if test="title!=''">
					<xsl:apply-templates select="title"/>
				</xsl:if>
				<xsl:if test="subtitle!=''">
					<xsl:apply-templates select="subtitle"/>
				</xsl:if>
				<xsl:apply-templates select="popupnav"/>
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template name="ReportFilters">
		<xsl:if test="filters[not(@tabs)]!=''">
			<div>
				<xsl:attribute name="class">
					<xsl:choose>
						<xsl:when test="not(filters[@tabs]) and not(summary[@spliter])">rprt-fil-none</xsl:when>
						<xsl:when test="filters[@tabs] and not(summary) and not(summary[@spliter])">rprt-fil-wtab</xsl:when>
						<xsl:otherwise>rprt-fil</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
				<xsl:apply-templates select="filters[not(@tabs)]"/>
			</div>
		</xsl:if>
	</xsl:template>

	<xsl:template name="ReportSummary">
		<xsl:choose>
			<xsl:when test="@total='yes'">
				<xsl:call-template name="Summary"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="summary"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="ReportTabs">
		<xsl:choose>
			<xsl:when test="filters[@tabs]">
				<xsl:apply-templates select="filters[@tabs]" mode="tabs"/>
			</xsl:when>
			<xsl:otherwise>
				<div class="rprt-shdw">
					<call-template name="nobrspace"/>
				</div>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="ReportAdd">
		<xsl:apply-templates select="head/heading[@type='item-add-multi']" mode="add-multi"/>
	</xsl:template>

	<xsl:template name="ReportData">
		<table id="Report-Data-rgn">
			<xsl:attribute name="class">
				<!-- AB: Some revision required here... -->
				<xsl:choose>
					<xsl:when test="head/heading[@type][@type='item-check-multi' or @type='item-edit-multi' or @type='item-add-multi' or @type='item-del-multi']"></xsl:when>
					<xsl:when test="not(filters[@tabs]) and not(@pages='yes') and not(filters[not(@tabs)])">bordered</xsl:when>
					<!--
					<xsl:when test="$device='print'">printed</xsl:when>
					-->
					<xsl:otherwise>rprt-data</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:apply-templates select="head" mode="columns"/>
			<thead>
				<xsl:apply-templates select="head"/>
			</thead>
			<tfoot>
				<xsl:apply-templates select="head"/>
			</tfoot>
			<tbody>
				<xsl:choose>
					<xsl:when test="count(item) &gt; 0 or count(items/item) &gt; 0">
						<xsl:apply-templates select="items"/>
						<xsl:call-template name="ReportItems"/>
					</xsl:when>
					<xsl:otherwise>
						<tr>
							<td>
								<xsl:if test="@summaryonly!='yes' or not(@summaryonly)">
									<xsl:attribute name="colspan">
										<xsl:value-of select="count(head/heading[not(@type) or @type!='item-edit' and @type!='item-del'])"/>
									</xsl:attribute>
									<h1 class="rprt-nodata">Sorry, there is no data available for what you've selected</h1>
								</xsl:if>
							</td>
						</tr>
					</xsl:otherwise>
				</xsl:choose>
			</tbody>
		</table>
	</xsl:template>

	<xsl:template name="ReportNav">
		<xsl:variable name="thispge">
			<xsl:choose>
				<xsl:when test="@Page_No!=''">
					<xsl:value-of select="number(@Page_No)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="number(pages/pageNumber)"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thistot">
			<xsl:choose>
				<xsl:when test="@pageTotal!=''">
					<xsl:value-of select="number(@pageTotal)"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="number(pages/pageTotal)"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="@name">
					<xsl:value-of select="@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$name_grp"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="not(@pages!='yes')">
				<div class="rprt-pge">
					<xsl:if test="$thispge!=1">
						<img src="images/ver5/icons/vcr-fst.gif">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:nm_grp.GoVcr('1', </xsl:text>
								<xsl:value-of select="$thisname"/>
								<xsl:text>)</xsl:text>
							</xsl:attribute>
						</img>
						<img src="images/ver5/icons/vcr-prv.gif">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:nm_grp.GoVcr('</xsl:text>
								<xsl:value-of select="$thispge - 1"/>
								<xsl:text>', </xsl:text>
								<xsl:value-of select="$thisname"/>
								<xsl:text>)</xsl:text>
							</xsl:attribute>
						</img>
					</xsl:if>
					<!-- page number selector -->
					<span class="rprt-pge-hint">page</span>
					<input type="Text" name="Page_No" size="3" title="Enter a page number to jump">
						<xsl:attribute name="value">
							<xsl:value-of select="$thispge"/>
						</xsl:attribute>
						<xsl:attribute name="onchange">
							<xsl:text>javascript:</xsl:text>
							<xsl:value-of select="$thisname"/>
							<xsl:text>.submit();</xsl:text>
						</xsl:attribute>
					</input>
					<span class="rprt-pge-hint">
						<xsl:text> of </xsl:text>
						<xsl:value-of select="$thistot"/>
					</span>
					<xsl:if test="$thispge!=$thistot">
						<img src="images/ver5/icons/vcr-nxt.gif">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:nm_grp.GoVcr('</xsl:text>
								<xsl:value-of select="$thispge + 1"/>
								<xsl:text>', </xsl:text>
								<xsl:value-of select="$thisname"/>
								<xsl:text>)</xsl:text>
							</xsl:attribute>
						</img>
						<img src="images/ver5/icons/vcr-lst.gif">
							<xsl:attribute name="onclick">
								<xsl:text>javascript:nm_grp.GoVcr('</xsl:text>
								<xsl:value-of select="$thistot"/>
								<xsl:text>', </xsl:text>
								<xsl:value-of select="$thisname"/>
								<xsl:text>)</xsl:text>
							</xsl:attribute>
						</img>
					</xsl:if>
					<xsl:if test="@button">
						<xsl:if test="@button!='none'">
							<div class="nm-rep-submit">
								<xsl:call-template name="FormButton">
									<xsl:with-param name="label" select="@button"/>
									<xsl:with-param name="type">submit</xsl:with-param>
									<xsl:with-param name="formname">
										<xsl:value-of select="$thisname"/>
									</xsl:with-param>
									<xsl:with-param name="document"/>
									<xsl:with-param name="important"/>
								</xsl:call-template>
								<!-- confirm also gets a 'back' button - same as below
									 this seems right, but has not been tested...
								<xsl:if test="@button='confirm'">
									<xsl:call-template name="FormButton">
										<xsl:with-param name="label">back</xsl:with-param>
										<xsl:with-param name="type">back</xsl:with-param>
									</xsl:call-template>
								</xsl:if>
								-->
							</div>
						</xsl:if>
					</xsl:if>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<!-- required for nm_grp.Sort to work ok-->
				<input type="Hidden" name="Page_No">
					<xsl:attribute name="value">
						<xsl:value-of select="@Page_No"/>
					</xsl:attribute>
				</input>
				<xsl:if test="(@button and @button!='none') or button">
					<div class="rprt-pge">
						<div class="nm-rep-submit">
							<xsl:if test="@button">
								<xsl:call-template name="FormButton">
									<xsl:with-param name="label" select="@button"/>
									<xsl:with-param name="type">submit</xsl:with-param>
									<xsl:with-param name="formname">
										<xsl:value-of select="$thisname"/>
									</xsl:with-param>
									<xsl:with-param name="document"/>
									<xsl:with-param name="important"/>
								</xsl:call-template>
								<xsl:if test="@button='confirm'">
									<!-- confirm also gets a 'back' button-->
									<xsl:call-template name="FormButton">
										<xsl:with-param name="label">back</xsl:with-param>
										<xsl:with-param name="type">back</xsl:with-param>
									</xsl:call-template>
								</xsl:if>
							</xsl:if>
							<xsl:apply-templates select="button"/>
						</div>
					</div>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="Item">
		<xsl:param name="value"/>
		<xsl:param name="id"/>
		<xsl:param name="position"/>
		<xsl:param name="ptr"/>
		<td>
			<xsl:choose>
				<xsl:when test="@type='edit' or @type='edit-check'">
					<input type="Text">
						<xsl:attribute name='size'>
							<xsl:choose>
								<xsl:when test="length">
									<xsl:value-of select='length'/>
								</xsl:when>
								<xsl:otherwise>15</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
						<xsl:attribute name='id'>
							item_<xsl:value-of select='$position'/>_<xsl:value-of select='$id'/>
						</xsl:attribute>
						<xsl:attribute name='name'>
							<xsl:choose>
								<xsl:when test="@type='edit-check'">
									editcheck_<xsl:value-of select='$id'/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select='@name'/>_<xsl:value-of select='$position'/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
						<xsl:attribute name='value'>
							<xsl:value-of select="$value"/>
						</xsl:attribute>
					</input>
				</xsl:when>
				<xsl:otherwise>
					<xsl:choose>
						<xsl:when test="popup">
							<a>
								<xsl:attribute name="href">
									<xsl:text>javascript:nm_pge.Pop('</xsl:text>
									<xsl:value-of select='$BaseLinkUrl'/>
									<xsl:value-of select='popup/@link'/>
									<xsl:if test="popup/@service and popup/@process">
										<xsl:text>&amp;service=</xsl:text>
										<xsl:value-of select='popup/@service'/>
										<xsl:text>&amp;process=</xsl:text>
										<xsl:value-of select='popup/@process'/>
									</xsl:if>
									<xsl:if test="$ptr">
										<xsl:text>&amp;id=</xsl:text>
										<xsl:value-of select="$ptr"/>
									</xsl:if>
									<xsl:text>', true, false, </xsl:text>
									<xsl:value-of select="popup/@width"/>
									<xsl:text>, </xsl:text>
									<xsl:value-of select="popup/@height"/>
									<xsl:text>, false)</xsl:text>
								</xsl:attribute>
								<xsl:value-of select="$value"/>
							</a>
						</xsl:when>
						<xsl:when test="(@service or @form or handler) and (@type!='item-add' or not(@type))">
							<a>
								<xsl:attribute name="href">
									<xsl:call-template name="ReportLink">
										<xsl:with-param name="sid">
											<xsl:text>ver5</xsl:text>
										</xsl:with-param>
									</xsl:call-template>
									<xsl:if test="$ptr">
										<xsl:text>&amp;id=</xsl:text>
										<xsl:value-of select="$ptr"/>
									</xsl:if>
								</xsl:attribute>
								<xsl:value-of select="$value"/>
							</a>
						</xsl:when>
						<xsl:otherwise>
							<xsl:choose>
								<xsl:when test="@format='rand'">
									<xsl:attribute name="class">
										<xsl:text>rht</xsl:text>
									</xsl:attribute>
									<xsl:text>R&#160;</xsl:text>
									<xsl:value-of select="format-number($value, '###,###.00')"/>
								</xsl:when>
								<xsl:when test="@format='integer'">
									<xsl:number value="$value" format="1"/>
								</xsl:when>
								<xsl:when test="@format='percent'">
									<xsl:attribute name="class">
										<xsl:text>rht</xsl:text>
									</xsl:attribute>
									<xsl:value-of select="format-number($value, '###.0')"/>
									<xsl:text>%</xsl:text>
								</xsl:when>
								<xsl:when test="@format='dateonly'">
									<xsl:attribute name="class">
										<xsl:text>rht</xsl:text>
									</xsl:attribute>
									<xsl:value-of select="substring($value, 1, 10)"/>
								</xsl:when>
								<xsl:when test="@format='timeonly'">
									<xsl:attribute name="class">
										<xsl:text>rht</xsl:text>
									</xsl:attribute>
									<xsl:value-of select="substring($value, 11, 12)"/>
								</xsl:when>
								<xsl:when test="@format='number'">
									<xsl:attribute name="class">
										<xsl:text>rht</xsl:text>
									</xsl:attribute>
									<xsl:value-of select="$value"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$value"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:otherwise>
			</xsl:choose>
		</td>
	</xsl:template>

	<xsl:template name="ItemPop">
		<xsl:param name="item"/>
		<xsl:param name="value"/>
		<td>
			<xsl:choose>
				<xsl:when test="@service or @form or handler">
					<a>
						<xsl:attribute name="href">
							<xsl:text>javascript:nm_pge.PopUp('</xsl:text>
							<xsl:call-template name="ReportLink">
								<xsl:with-param name="sid">
									<xsl:text>ver5_popup</xsl:text>
								</xsl:with-param>
							</xsl:call-template>
							<xsl:for-each select="param">
								<xsl:variable name="thisname" select="@name"/>
								<xsl:text>&amp;</xsl:text>
								<xsl:value-of select="."/>
								<xsl:text>=</xsl:text>
								<xsl:value-of select="$item/@*[name()=$thisname]"/>
							</xsl:for-each>
							<xsl:text>');</xsl:text>
						</xsl:attribute>
						<xsl:value-of select="$value"/>
					</a>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$value"/>
				</xsl:otherwise>
			</xsl:choose>
		</td>
	</xsl:template>

	<xsl:template name="ItemType">
		<xsl:param name="item"/>
		<xsl:param name="value"/>
		<xsl:param name="id"/>
		<xsl:param name="position"/>
		<!-- apply same class as column head (see template match="grpform/head") -->
		<xsl:if test="not($device='print' or $device='email')">
			<td>
				<xsl:choose>
					<xsl:when test="@type='item-check-multi'">
						<xsl:attribute name="class">td-chk</xsl:attribute>
					</xsl:when>
					<xsl:when test="@type='menubutton' 
							or @type='item-query'
							or @type='item-del'
							or @type='item-edit'
							or @type='item-edit-del'
							or @type='item-go'
							or @type='item-btn'
							or @type='item-edit-multi'
							or @type='item-del-multi'
							or @type='item-drop-values'
							or @type='item-drop'
							or @type='item-drop-go'
							or @type='item-drop-doc'
							or @type='item-check'">
						<xsl:attribute name="class">td-aed</xsl:attribute>
					</xsl:when>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="@type='menubutton'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Go</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-query'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Query</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-del'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">
								<xsl:choose>
									<xsl:when test=".!=''">
										<xsl:value-of select="."/>
									</xsl:when>
									<xsl:otherwise>Delete</xsl:otherwise>
								</xsl:choose>
							</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-edit'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Edit</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-edit-del'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Edit</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Delete</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-go'">
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Go</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-btn'">
						<xsl:call-template name="ItemButton">
							<xsl:with-param name="id" select='$id'/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-check-multi'">
						<xsl:call-template name="ReportCheck">
							<xsl:with-param name="label">
								<xsl:if test="@hint!=''">
									<xsl:value-of select="@hint"/>
								</xsl:if>
							</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name">check_</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-edit-multi'">
						<xsl:call-template name="ReportCheck">
							<xsl:with-param name="label">Edit</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name">edit_</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-del-multi'">
						<xsl:call-template name="ReportCheck">
							<xsl:with-param name="label">Delete</xsl:with-param>
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name">delete_</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-check'">
						<xsl:call-template name="ReportCheck">
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name">item_</xsl:with-param>
							<xsl:with-param name="nameid" select="$position"/>
							<xsl:with-param name="checked" select="$value"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-drop'">
						<!-- assume can only have one for now
					<xsl:attribute name="class"><xsl:text>grp-msg-cell-inp</xsl:text></xsl:attribute> -->
						<xsl:variable name="chkattr" select="check/@name"/>
						<xsl:variable name="chkval" select="number($item/attribute::*[name()=$chkattr])"/>
						<xsl:choose>
							<xsl:when test="$value = ''">
								<span class="grp-msg-text">
									<xsl:call-template name="nobrspace"/>
								</span>
							</xsl:when>
							<xsl:when test="$value &lt; 0">
								<span class="grp-msg-text">
									<xsl:value-of select="subobjs/subwf_obj[value=$value]/prompt"/>
								</span>
							</xsl:when>
							<xsl:otherwise>
								<xsl:variable name="formname" select="ancestor::grpform/@name" />
								<xsl:choose>
									<xsl:when test="$chkval='NaN' or $chkval=0">
										<span class="grp-msg-text">
											<xsl:value-of select="check/prompt"/>
										</span>
									</xsl:when>
									<xsl:otherwise>
										<input type="Hidden" value=''>
											<xsl:attribute name='name'>
												<xsl:text>change_</xsl:text>
												<xsl:value-of select='$id'/>
											</xsl:attribute>
										</input>
										<select>
											<xsl:attribute name="onmouseover">javascript:nm_pge.DropShowHide(this)</xsl:attribute>
											<xsl:attribute name='id'>
												<xsl:value-of select='$id'/>
											</xsl:attribute>
											<xsl:attribute name='name'>
												<xsl:text>select_</xsl:text>
												<xsl:value-of select='$id'/>
											</xsl:attribute>
											<xsl:attribute name="onchange">
												<xsl:text>javascript:nm_grp.ChangeValue(</xsl:text>
												<xsl:value-of select="$formname"/>.change_<xsl:value-of select="$id"/>
												<xsl:text>, this.value);</xsl:text>
											</xsl:attribute>
											<xsl:for-each select='subobjs/subwf_obj[value &gt;= 0]'>
												<option>
													<xsl:attribute name='value'>
														<xsl:value-of select='value'/>
													</xsl:attribute>
													<xsl:if test="value=$value">
														<xsl:attribute name='selected'></xsl:attribute>
													</xsl:if>
													<xsl:value-of select='prompt'/>
													<xsl:value-of select='prompt2'/>
												</option>
											</xsl:for-each>
										</select>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@type='item-drop-values'">
						<!-- like item-drop, but only puts values greater than...
					<xsl:attribute name="class"><xsl:text>grp-msg-cell-inp</xsl:text></xsl:attribute> -->
						<xsl:variable name="chkattr" select="check/@name"/>
						<xsl:variable name="chkval" select="number($item/attribute::*[name()=$chkattr])"/>
						<xsl:variable name="chkobjs" select="check_subobjs/@name"/>
						<xsl:variable name="chksub" select="$item/attribute::*[name()=$chkobjs]"/>
						<xsl:choose>
							<xsl:when test="$value = ''">
								<xsl:call-template name="nobrspace"/>
							</xsl:when>
							<xsl:when test="$value &lt; 0">
								<xsl:value-of select="subobjs/subwf_obj[value=$value]/prompt"/>
								<xsl:value-of select="subobjs/subwf_obj[value=$value]/prompt2"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:choose>
									<xsl:when test="$chkval='NaN' or $chkval=0">
										<xsl:value-of select="check/prompt"/>
									</xsl:when>
									<xsl:otherwise>
										<select>
											<xsl:attribute name="onmouseover">javascript:nm_pge.DropShowHide(this)</xsl:attribute>
											<xsl:attribute name='id'>
												<xsl:value-of select='$id'/>
											</xsl:attribute>
											<xsl:attribute name='name'>
												select_<xsl:value-of select='$id'/>
											</xsl:attribute>
											<xsl:choose>
												<xsl:when test="$chkobjs !=''">
													<xsl:for-each select='subobjs[@check = $chksub]/subwf_obj[value &gt;= 0]'>
														<xsl:variable name="subval" select="number(substring-after(prompt, 'R'))"/>
														<xsl:if test="$chkval &gt;= $subval or value = 0">
															<option>
																<xsl:attribute name='value'>
																	<xsl:value-of select='value'/>
																</xsl:attribute>
																<xsl:if test="value=$value">
																	<xsl:attribute name='selected'></xsl:attribute>
																</xsl:if>
																<xsl:value-of select='prompt'/>
															</option>
														</xsl:if>
													</xsl:for-each>
												</xsl:when>

												<xsl:otherwise>
													<xsl:for-each select='subobjs/subwf_obj[value &gt;= 0]'>
														<xsl:variable name="subval" select="number(substring-after(prompt, 'R'))"/>
														<xsl:if test="$chkval &gt;= $subval or value = 0">
															<option>
																<xsl:attribute name='value'>
																	<xsl:value-of select='value'/>
																</xsl:attribute>
																<xsl:if test="value=$value">
																	<xsl:attribute name='selected'></xsl:attribute>
																</xsl:if>
																<xsl:value-of select='prompt'/>
															</option>
														</xsl:if>
													</xsl:for-each>
												</xsl:otherwise>
											</xsl:choose>
										</select>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@type='item-drop-go'">
						<!-- assume can only have one for now -->
						<xsl:variable name="thisname">
							<xsl:text>Drop_Go_</xsl:text>
							<xsl:value-of select="$id"/>
						</xsl:variable>
						<select>
							<xsl:attribute name="onmouseover">javascript:nm_pge.DropShowHide(this)</xsl:attribute>
							<xsl:attribute name="id">
								<xsl:value-of select="$id"/>
							</xsl:attribute>
							<xsl:attribute name="name">
								<xsl:value-of select="$thisname"/>
							</xsl:attribute>
							<xsl:call-template name="select_class"/>
							<xsl:for-each select="subobjs/subwf_obj">
								<option>
									<xsl:attribute name="value">
										<xsl:value-of select="value"/>
									</xsl:attribute>
									<xsl:value-of select="prompt"/>
								</option>
							</xsl:for-each>
						</select>
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Go</xsl:with-param>
							<xsl:with-param name="ref" select="$thisname"/>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-drop-doc'">
						<!-- assume can only have one for now -->
						<xsl:variable name="thisname">
							<xsl:text>Drop_Go_</xsl:text>
							<xsl:value-of select="$id"/>
						</xsl:variable>
						<select>
							<xsl:attribute name="onmouseover">javascript:nm_pge.DropShowHide(this)</xsl:attribute>
							<xsl:attribute name="id">
								<xsl:value-of select="$id"/>
							</xsl:attribute>
							<xsl:attribute name="name">
								<xsl:value-of select="$thisname"/>
							</xsl:attribute>
							<xsl:call-template name="select_class"/>
							<xsl:for-each select='subobjs/subwf_obj'>
								<option>
									<xsl:attribute name="value">
										<xsl:apply-templates select="value/action"/>
									</xsl:attribute>
									<xsl:value-of select="prompt"/>
								</option>
							</xsl:for-each>
						</select>
						<xsl:call-template name="ReportButton">
							<xsl:with-param name="label">Go</xsl:with-param>
							<xsl:with-param name="ref" select="$thisname"/>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@type='item-enum'">
						<!-- similar to item-drop, but only referenced (eg the confirms of an item-drop) -->
						<xsl:value-of select="subobjs/subwf_obj[value=$value]/prompt"/>
					</xsl:when>
					<xsl:when test="@type='item-date'">
						<!-- expects datatime string eg: '2002-11-02T22:10:35' (Sortable date/time pattern; conforms to ISO 8601)-->
						<xsl:value-of select="substring-before($value, 'T')"/>
					</xsl:when>
					<xsl:when test="@type='item-time'">
						<!-- expects datatime string eg: '2002-11-02T22:10:35' (Sortable date/time pattern; conforms to ISO 8601)-->
						<xsl:value-of select="substring-after($value, 'T')"/>
					</xsl:when>
					<xsl:when test="@type='item-radio'">
						<xsl:variable name="thisname">
							<xsl:choose>
								<xsl:when test="ancestor-or-self::grpform/@name">
									<xsl:value-of select="ancestor-or-self::grpform/@name"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$name_grp"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="thislink">
							<xsl:choose>
								<xsl:when test="@link">
									<xsl:value-of select="@link"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$link"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<input type="radio">
							<xsl:attribute name="value">
								<xsl:value-of select="$id"/>
							</xsl:attribute>
							<xsl:attribute name="id">Radio_Sel</xsl:attribute>
							<xsl:attribute name="name">Radio_Sel</xsl:attribute>
							<xsl:choose>
								<xsl:when test="$value='Y' or $value='yes'">
									<xsl:attribute name="checked">checked</xsl:attribute>
								</xsl:when>
								<xsl:otherwise>
									<xsl:attribute name="onclick">
										<xsl:call-template name="ButtonAction">
											<xsl:with-param name="form" select="$thisname"/>
											<xsl:with-param name="type">service</xsl:with-param>
											<xsl:with-param name="link" select="$thislink"/>
											<xsl:with-param name="name" select="@service"/>
											<xsl:with-param name="proc" select="@process"/>
										</xsl:call-template>
									</xsl:attribute>
								</xsl:otherwise>
							</xsl:choose>
						</input>
					</xsl:when>
					<xsl:when test="@type=''">
					</xsl:when>
					<xsl:otherwise>
					</xsl:otherwise>
				</xsl:choose>
			</td>
		</xsl:if>
	</xsl:template>

	<!--=========================
	Utility templates section
	========================= -->

	<xsl:template name="HeadButton">
		<xsl:param name="label"/>
		<xsl:param name="multi"/>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="ancestor-or-self::grpform/@name">
					<xsl:value-of select="ancestor-or-self::grpform/@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$name_grp"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thislink">
			<xsl:choose>
				<xsl:when test="@link">
					<xsl:value-of select="@link"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$link"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:if test="$multi='yes'">
			<select class="s-s">
				<xsl:attribute name="onmouseover">javascript:nm_pge.DropShowHide(this)</xsl:attribute>
				<xsl:attribute name="name">
					<xsl:text>add_</xsl:text>
					<xsl:value-of select="@name"/>
				</xsl:attribute>
				<option value='1'>1</option>
				<option value='2'>2</option>
				<option value='3'>3</option>
				<option value='4'>4</option>
				<option value='5'>5</option>
				<option value='6'>6</option>
				<option value='7'>7</option>
				<option value='8'>8</option>
				<option value='9'>9</option>
				<option value='10'>10</option>
			</select>
		</xsl:if>
		<input type="Button">
			<xsl:attribute name="value">
				<xsl:choose>
					<xsl:when test="$label">
						<xsl:value-of select="$label"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>Submit</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="$multi='yes'">rprt-btn norm aed</xsl:when>
					<xsl:when test="@type='item-check-multi'">rprt-chk</xsl:when>
					<xsl:when test="@button='lolight'">rprt-btn lo</xsl:when>
					<xsl:otherwise>rprt-btn aed</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:attribute name="onclick">
				<xsl:choose>
					<xsl:when test="@form">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">form</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="name" select="@form"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@service">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">service</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="name" select="@service"/>
							<xsl:with-param name="proc" select="@process"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@link">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">link</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="ReportButton">
		<xsl:param name="label"/>
		<xsl:param name="id"/>
		<xsl:param name="ref"/>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="ancestor-or-self::grpform/@name">
					<xsl:value-of select="ancestor-or-self::grpform/@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$name_grp"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thislink">
			<xsl:choose>
				<xsl:when test="@link">
					<xsl:value-of select="@link"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$link"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<input type="Button" class="rprt-btn aed">
			<xsl:if test="@button='lolight'">
				<xsl:attribute name="class">rprt-btn lo</xsl:attribute>
			</xsl:if>
			<xsl:attribute name="value">
				<xsl:value-of select="$label"/>
			</xsl:attribute>
			<xsl:attribute name="onclick">
				<xsl:choose>
					<xsl:when test="@type='menubutton'">
						<xsl:text>nm_pge.MenuMove()</xsl:text>
						<!--
						<xsl:text>nm_pge.MoveMenu(</xsl:text>
						<xsl:value-of select="$id"/>
						<xsl:text>)</xsl:text>
						-->
					</xsl:when>
					<xsl:when test="@type='item-drop-doc'">
						<xsl:text>nm_grp.GoDropDoc(</xsl:text>
						<xsl:value-of select="$ref"/>
						<xsl:text>, '</xsl:text>
						<xsl:value-of select="$id"/>
						<xsl:text>')</xsl:text>
					</xsl:when>
					<xsl:when test="@type='item-drop-go'">
						<xsl:text>nm_grp.GoDrop('</xsl:text>
						<xsl:apply-templates select="action"/>
						<!-- fools the proxy to not get url from cache - used very selectively for now
						<xsl:text>&amp;prxid=</xsl:text>
						<xsl:value-of select="$this_rand"/>
						 -->
						<xsl:choose>
							<xsl:when test="@subtype='handler'">
								<xsl:text>&amp;process=</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>&amp;lnk=</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text>', </xsl:text>
						<xsl:value-of select="$ref"/>
						<xsl:text>, '</xsl:text>
						<xsl:value-of select="$id"/>
						<xsl:text>', </xsl:text>
						<xsl:choose>
							<xsl:when test="@pop">
								<xsl:text>true</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>false</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text>)</xsl:text>
					</xsl:when>
					<xsl:when test="@form">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">form</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name" select="@form"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@service">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">service</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="id" select="$id"/>
							<xsl:with-param name="name" select="@service"/>
							<xsl:with-param name="proc" select="@process"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@link">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">link</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="ItemButton">
		<xsl:param name="label"/>
		<xsl:param name="id"/>
		<xsl:variable name="thisname">
			<xsl:choose>
				<xsl:when test="ancestor-or-self::grpform/@name">
					<xsl:value-of select="ancestor-or-self::grpform/@name"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$name_grp"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="thislink">
			<xsl:choose>
				<xsl:when test="@link">
					<xsl:value-of select="@link"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$link"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<input type="Button" class="rprt-btn aed">
			<xsl:attribute name="value">
				<xsl:choose>
					<xsl:when test="$label">
						<xsl:value-of select="$label"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="."/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:attribute name="onclick">
				<xsl:choose>
					<xsl:when test="@action='back'">javascript:prevpage()</xsl:when>
					<xsl:when test="@form">
						<xsl:choose>
							<xsl:when test="@name='Edit' or @name='Delete'">
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="checks">yes</xsl:with-param>
									<xsl:with-param name="form" select="$thisname"/>
									<xsl:with-param name="type">form</xsl:with-param>
									<xsl:with-param name="link" select="$thislink"/>
									<xsl:with-param name="id" select="$id"/>
									<xsl:with-param name="name" select="@form"/>
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="form" select="$thisname"/>
									<xsl:with-param name="type">form</xsl:with-param>
									<xsl:with-param name="link" select="$thislink"/>
									<xsl:with-param name="id" select="$id"/>
									<xsl:with-param name="name" select="@form"/>
								</xsl:call-template>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@service">
						<xsl:choose>
							<xsl:when test="@name='Edit' or @name='Delete'">
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="checks">yes</xsl:with-param>
									<xsl:with-param name="form" select="$thisname"/>
									<xsl:with-param name="type">service</xsl:with-param>
									<xsl:with-param name="link" select="$thislink"/>
									<xsl:with-param name="id" select="$id"/>
									<xsl:with-param name="name" select="@service"/>
									<xsl:with-param name="proc" select="@process"/>
								</xsl:call-template>
							</xsl:when>
							<xsl:when test="@name='Download'">
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="base">nm_data.asp?link=</xsl:with-param>
									<xsl:with-param name="form" select="$thisname"/>
									<xsl:with-param name="type">service</xsl:with-param>
									<xsl:with-param name="link" select="$thislink"/>
									<xsl:with-param name="id" select="$id"/>
									<xsl:with-param name="name" select="@service"/>
									<xsl:with-param name="proc" select="@process"/>
									<xsl:with-param name="param">device=data</xsl:with-param>
								</xsl:call-template>
							</xsl:when>
							<xsl:otherwise>
								<xsl:call-template name="ButtonAction">
									<xsl:with-param name="form" select="$thisname"/>
									<xsl:with-param name="type">service</xsl:with-param>
									<xsl:with-param name="link" select="$thislink"/>
									<xsl:with-param name="id" select="$id"/>
									<xsl:with-param name="name" select="@service"/>
									<xsl:with-param name="proc" select="@process"/>
								</xsl:call-template>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:when test="@link">
						<xsl:call-template name="ButtonAction">
							<xsl:with-param name="form" select="$thisname"/>
							<xsl:with-param name="type">link</xsl:with-param>
							<xsl:with-param name="link" select="$thislink"/>
							<xsl:with-param name="id" select="$id"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>javascript:nm_grp.Send(</xsl:text>
						<xsl:value-of select="$thisname"/>
						<xsl:text>, </xsl:text>
						<xsl:choose>
							<xsl:when test="ancestor-or-self::grpform/head/heading[@checkselect='yes']">
								<xsl:text>true, '</xsl:text>
								<xsl:value-of select="ancestor-or-self::grpform/head/heading[@checkselect='yes']/@prompt"/>
								<xsl:text>'</xsl:text>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>false, ''</xsl:text>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text>)</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		</input>
	</xsl:template>

	<!-- called as:
		<xsl:call-template name="ButtonAction">
			<xsl:with-param name="secure"/>
			<xsl:with-param name="base"/>
			<xsl:with-param name="form"/>
			<xsl:with-param name="type"/>
			<xsl:with-param name="name"/>
			<xsl:with-param name="link"/>
			<xsl:with-param name="id"/>
			<xsl:with-param name="proc"/>
			<xsl:with-param name="param"/>
		</xsl:call-template>
	-->

	<xsl:template name="ButtonAction">
		<xsl:param name="checks"/>
		<!-- opt -->
		<xsl:param name="secure"/>
		<!-- opt -->
		<xsl:param name="base"/>
		<!-- opt -->
		<xsl:param name="form"/>
		<!-- mand -->
		<xsl:param name="type"/>
		<!-- mand -->
		<xsl:param name="link"/>
		<!-- mand -->
		<xsl:param name="name"/>
		<!-- opt -->
		<xsl:param name="id"/>
		<!-- opt -->
		<xsl:param name="proc"/>
		<!-- opt -->
		<xsl:param name="param"/>
		<!-- opt -->
		<xsl:choose>
			<xsl:when test="$checks='yes'">
				<xsl:text>javascript:nm_grp.ValidChks(</xsl:text>
			</xsl:when>
			<xsl:when test="@pop='yes'">
				<xsl:text>javascript:nm_pge.</xsl:text>
				<xsl:value-of select="@pop_func"/>
				<xsl:text>('</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>javascript:nm_grp.Submit(</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="not(@pop)">
			<xsl:value-of select="$form"/>
			<xsl:text>, '</xsl:text>
		</xsl:if>
		<!-- delete?
		<xsl:choose>
			<xsl:when test="$secure='yes'">
				<xsl:value-of select='$nm_secureurl'/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select='$nm_serverurl'/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="$base">
				<xsl:value-of select="$base"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$nm_baseurl"/>
			</xsl:otherwise>
		</xsl:choose>
		-->
		<xsl:value-of select="$BaseLinkUrl"/>
		<xsl:value-of select="$link"/>
		<xsl:choose>
			<xsl:when test="$type='form'">
				<xsl:text>&amp;form=</xsl:text>
				<xsl:value-of select="$name"/>
			</xsl:when>
			<xsl:when test="$type='service'">
				<xsl:text>&amp;service=</xsl:text>
				<xsl:value-of select="$name"/>
				<xsl:text>&amp;process=</xsl:text>
				<xsl:value-of select="$proc"/>
			</xsl:when>
			<xsl:when test="$type='handler'">
				<xsl:text>&amp;handler=</xsl:text>
				<xsl:value-of select="$name"/>
				<xsl:text>&amp;process=</xsl:text>
				<xsl:value-of select="$proc"/>
			</xsl:when>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="@pop='yes'">
				<xsl:text>&amp;id=</xsl:text>
				<xsl:value-of select="$id"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>', '</xsl:text>
				<xsl:value-of select="$id"/>
				<xsl:text>', '</xsl:text>
				<xsl:value-of select="$param"/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:text>')</xsl:text>
	</xsl:template>

	<xsl:template name="ReportCheck">
		<xsl:param name="label"/>
		<xsl:param name="id"/>
		<xsl:param name="name"/>
		<xsl:param name="nameid"/>
		<xsl:param name="checked"/>
		<input type="Checkbox">
			<xsl:attribute name="id">
				<xsl:value-of select="$id"/>
			</xsl:attribute>
			<xsl:attribute name="name">
				<xsl:value-of select="$name"/>
				<xsl:choose>
					<xsl:when test="$nameid!=''">
						<xsl:value-of select="$nameid"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$id"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			<xsl:if test="$checked='yes'">
				<xsl:attribute name="checked"></xsl:attribute>
			</xsl:if>
		</input>
		<xsl:call-template name="nobrspace"/>
		<xsl:value-of select="$label"/>
	</xsl:template>

	<xsl:template name="ReportLink">
		<xsl:param name="sid"/>
		<xsl:choose>
			<xsl:when test="handler">
				<xsl:apply-templates select="handler"/>
			</xsl:when>
			<xsl:otherwise>
				<!-- delete?
				<xsl:choose>
					<xsl:when test="@secure='yes'">
						<xsl:value-of select='$nm_secureurl'/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select='$nm_serverurl'/>
					</xsl:otherwise>
				</xsl:choose>
				-->
				<xsl:value-of select='$BaseLinkUrl'/>
				<xsl:choose>
					<xsl:when test="@link">
						<xsl:value-of select="@link"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$link"/>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="@service">
						<xsl:text>&amp;service=</xsl:text>
						<xsl:value-of select="@service"/>
						<xsl:text>&amp;process=</xsl:text>
						<xsl:value-of select="@process"/>
					</xsl:when>
					<xsl:when test="@form">
						<xsl:text>&amp;form=</xsl:text>
						<xsl:value-of select="@form"/>
					</xsl:when>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="ReportPrintEmailHeader">
		<div class="rprt-adr">
			<!-- replace with appropriate markup:
			<b>Nashua Mobile (Pty) Ltd</b>
			<br/>Reg No: 1986/004789/07 VatNo: 4660140494
			<br/>42 James Crescent, Halfway House, Midrand
			<div>
				<b>Sales:&#160;</b>
				<span class="red-tx">
					<xsl:value-of select="$telno_sales"/>
				</span>
			</div>
			<div>
				<b>&#160;Client Services:&#160;</b>
				<span class="red-tx">
					<xsl:value-of select="$telno_cs"/>
				</span>
			</div>
			-->
		</div>
	</xsl:template>

</xsl:stylesheet>
